package com.disability_federation.mapper;

import com.disability_federation.pojo.AuditList;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 职工审核名单-数据库接口
 */
@Mapper
public interface MapperAuditList {

    //查询全部审核名单
    //默认时间升序排序
    @Select("select * from audit_list.audit_list order by update_time")
    List<AuditList> query();

    //查询全部审核名单
    //时间降序排序
    @Select("select * from audit_list.audit_list order by update_time desc")
    List<AuditList> queryDesc();

    //查询全部审核名单
    //姓名升序排序
    @Select("select * from audit_list.audit_list order by name")
    List<AuditList> queryNameAsc();

    //查询全部审核名单
    //姓名降序排序
    @Select("select * from audit_list.audit_list order by name desc")
    List<AuditList> queryNameDesc();

    //查询全部审核名单
    //单位升序排序
    @Select("select * from audit_list.audit_list order by unit")
    List<AuditList> queryUnitAsc();

    //查询全部审核名单
    //单位降序排序
    @Select("select * from audit_list.audit_list order by unit desc")
    List<AuditList> queryUnitDesc();

    //查询全部审核名单
    //注册时间升序排序
    @Select("select * from audit_list.audit_list order by register_time")
    List<AuditList> queryRegisterTimeAsc();

    //查询全部审核名单
    //注册时间降序排序
    @Select("select * from audit_list.audit_list order by register_time desc")
    List<AuditList> queryRegisterTimeDesc();

    //查询全部审核名单
    //上次登录时间升序排序
    @Select("select * from audit_list.audit_list order by login_time")
    List<AuditList> queryLastLoginTimeAsc();

    //查询全部审核名单
    //上次登录时间降序排序
    @Select("select * from audit_list.audit_list order by login_time desc")
    List<AuditList> queryLastLoginTimeDesc();

    //条件查询
    //默认时间升序排序
    List<AuditList> queryCondition(String name, String unit);

    //条件查询
    //时间降序排序
    List<AuditList> queryConditionDesc(String name, String unit);

    //条件查询
    //姓名升序排序
    List<AuditList> queryConditionNameAsc(String name, String unit);

    //条件查询
    //姓名降序排序
    List<AuditList> queryConditionNameDesc(String name, String unit);

    //条件查询
    //单位升序排序
    List<AuditList> queryConditionUnitAsc(String name, String unit);

    //条件查询
    //单位降序排序
    List<AuditList> queryConditionUnitDesc(String name, String unit);

    //条件查询
    //注册时间升序排序
    List<AuditList> queryConditionRegisterTimeAsc(String name, String unit);

    //条件查询
    //注册时间降序排序
    List<AuditList> queryConditionRegisterTimeDesc(String name, String unit);

    //条件查询
    //上次登录时间升序排序
    List<AuditList> queryConditionLastLoginTimeAsc(String name, String unit);

    //条件查询
    //上次登录时间降序排序
    List<AuditList> queryConditionLastLoginTimeDesc(String name, String unit);

    //添加
    @Options(useGeneratedKeys = true, keyProperty = "id")//插入成功后，将主键值回填到mybatisUser对象中
    @Insert("insert into audit_list.audit_list(username, password, name, birthday, gender, phone, email, unit, update_time, register_time)"  +
            "value (#{username}, #{password}, #{name}, #{birthday}, #{gender}, #{phone}, #{email}, #{unit}, #{updateTime}, #{registerTime})")
    Integer add(AuditList auditList);

    //删除
    @Delete("delete from audit_list.audit_list where id=#{id}")
    Integer delete(Integer id);

    //批量删除
    Integer deleteBatch(Integer[] ids);

    //更新
    Integer update(AuditList auditList);

}
